import { ref, computed, reactive } from 'vue'
import { defineStore } from 'pinia'

const tokenStr = localStorage.getItem("webman_token");
let tokenObj = {}
if (tokenStr) {
    tokenObj = JSON.parse(tokenStr)
}
//用户信息
const userStore = defineStore('user', () => {
    const user = ref(tokenObj)
    const token = computed(() => 'Bearer ' + user.value.access_token)
    function initUser(obj) {
        user.value = obj
    }

    return { user, token, initUser }
})

export default userStore;